package com.contain2.generator.map;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import com.generic.genericinterface.demo1.Generator;

/**
 * 
 * 
 * @author Administrator
 * 
 * @param <T>
 */
public class CollectionData<K, V> extends LinkedHashMap<K, V> {

	public CollectionData(Generator<Pair<K, V>> gen, int quantity) {
		for (int i = 0; i < quantity; i++) {
			Pair<K, V> p = gen.next();
			put(p.key, p.value);
		}
	}

	public CollectionData(Generator<K> genK, Generator<V> genV, int quantity) {
		for (int i = 0; i < quantity; i++) {
			put(genK.next(), genV.next());
		}
	}

	public CollectionData(Generator<K> genK, V value, int quantity) {
		for (int i = 0; i < quantity; i++) {
			put(genK.next(), value);
		}
	}

	public CollectionData(Iterable<K> genK, Generator<V> genV) {
		for (K key : genK) {
			put(key, genV.next());
		}
	}

	public CollectionData(Iterable<K> genK, V value) {
		for (K key : genK) {
			put(key, value);
		}
	}

	public static <K, V> CollectionData<K, V> map(Generator<Pair<K, V>> gen,
			int quantity) {
		return new CollectionData<K, V>(gen, quantity);
	}

	public static <K, V> CollectionData<K, V> map(Generator<K> genK,
			Generator<V> genV, int quantity) {
		return new CollectionData<K, V>(genK, genV, quantity);
	}

	public static <K, V> CollectionData<K, V> map(Generator<K> genK, V value,
			int quantity) {
		return new CollectionData<K, V>(genK, value, quantity);
	}

	public static <K, V> CollectionData<K, V> map(Iterable<K> genK,
			Generator<V> genV) {
		return new CollectionData<K, V>(genK, genV);
	}

	public static <K, V> CollectionData<K, V> map(Iterable<K> genK, V value) {
		return new CollectionData<K, V>(genK, value);
	}

}
